/*   1:    */ package com.atomikos.datasource.xa;
/*   2:    */ 
/*   3:    */ import com.atomikos.datasource.ResourceException;
/*   4:    */ import javax.transaction.xa.XAException;
/*   5:    */ import javax.transaction.xa.XAResource;
/*   6:    */ 
/*   7:    */ public class TemporaryXATransactionalResource
/*   8:    */   extends XATransactionalResource
/*   9:    */ {
/*  10:    */   private static final int MAX_BYTES = 45;
/*  11:    */   
/*  12:    */   private static final String truncateNameTo45Bytes(String name)
/*  13:    */   {
/*  14: 61 */     String ret = name;
/*  15: 62 */     if (ret.getBytes().length > 45) {
/*  16: 63 */       ret = name.substring(0, 45);
/*  17:    */     }
/*  18: 67 */     if (ret.getBytes().length > 45) {
/*  19: 68 */       ret = name.substring(0, 22);
/*  20:    */     }
/*  21: 70 */     return ret;
/*  22:    */   }
/*  23:    */   
/*  24:    */   public TemporaryXATransactionalResource(XAResource xares)
/*  25:    */   {
/*  26: 75 */     super(truncateNameTo45Bytes(xares.toString()));
/*  27: 76 */     this.xares_ = xares;
/*  28:    */     
/*  29:    */ 
/*  30:    */ 
/*  31: 80 */     getXAResource();
/*  32:    */     try
/*  33:    */     {
/*  34: 83 */       if (!xares.isSameRM(xares)) {
/*  35: 84 */         printMsg("XAResource " + xares + " of class " + xares.getClass().getName() + " does not correctly implement isSameRM(): " + "use explicit resource registration to save memory.", 1);
/*  36:    */       }
/*  37:    */     }
/*  38:    */     catch (XAException e) {}
/*  39:    */   }
/*  40:    */   
/*  41:    */   protected XAResource refreshXAConnection()
/*  42:    */     throws ResourceException
/*  43:    */   {
/*  44:102 */     return this.xares_;
/*  45:    */   }
/*  46:    */   
/*  47:    */   public boolean isClosed()
/*  48:    */   {
/*  49:107 */     return needsRefresh();
/*  50:    */   }
/*  51:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions-jta\3.7.0\transactions-jta-3.7.0.jar
 * Qualified Name:     com.atomikos.datasource.xa.TemporaryXATransactionalResource
 * JD-Core Version:    0.7.0.1
 */